﻿using UnityEngine;
using System.Collections;

public class TestNGUITween : MonoBehaviour
{
	public UIPlayTween testUIPlayTween;

	public TweenPosition tweenPosition;

	public bool isForward = true;

	void Start ()
	{
		testUIPlayTween.OnFinished.AddListener(delegate()
		{
			Debug.Log("Finish");
		});
	}

	public void DebugLog()
	{
		Debug.Log("---1");
	}

	void Update ()
	{
		if(Input.GetKeyUp(KeyCode.P))
		{
			testUIPlayTween.Play(isForward);
		}

		if(Input.GetKeyUp(KeyCode.O))
		{
			testUIPlayTween.Play(!isForward);
		}

		if(Input.GetKeyUp(KeyCode.L))
		{
			StartCoroutine(DelayPlay1());
		}

		if(Input.GetKeyUp(KeyCode.K))
		{
			StartCoroutine(DelayPlay2());
		}
	}

	IEnumerator DelayPlay1()
	{
		testUIPlayTween.Play(isForward);
		yield return new WaitForFixedUpdate();
		tweenPosition.tweenFactor = 1.0f;
	}

	IEnumerator DelayPlay2()
	{
		testUIPlayTween.Play(!isForward);
		yield return new WaitForFixedUpdate();
		tweenPosition.tweenFactor = 0.0f;
	}
}
